<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  
  .big{
    border-radius: 20px;
    position: absolute;
    /* margin-top: 80px; */
    width:800px;
    height: 50px;
    background-color: blue;
  }
  .yuan{
    border-radius: 50%;
    position: relative;
    top:-40%;
    width: 100px;
    height: 100px;
    background-color: red;
    /* position: absolute; */
  }
</style>
<body>
  <h2>分数: <span>0</span></h2>
  <div class="big">
    <div class="yuan"></div>
  </div>
</body>
<script>
  // 获取元素
  const span = document.querySelector('span');
  const yuan = document.querySelector('.yuan');
  const big = document.querySelector('.big');
  // console.log(yuan);
  // yuan.addEventListener('click',function(){
    big.onmousemove = function(event){
    let left = event.clientX
    // let top = event.clientY
    yuan.style.left = left +'px'
    // yuan.style.top = top +'px'
    if(left<=800){span.innerHTML = Math.floor(left/800*100)}
    // span.innerHTML = Math.floor(left/800*100)
  }
  // })
 
</script>
</html>